-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): update orderLine on applyPriceAdjustments #2663
base: minor
Are you sure you want to change the base?
fix(core): update orderLine on applyPriceAdjustments #2663
Conversation
I'm not sure how this is any different from how it currently works, is it returning a different result?
The way I read this, |
Yes, it was not working for some reason but it did when I changed exact those patched lines in this commit directly in my node_modules. I have a customField for discount on orderLines and i was using applyPriceAdjustments to trigger OrderItemPriceCalculationStrategy for price recalculation. To further extend, price was not updated in order_line table as well. And it works now after those changes. |
Hi, It is not clear to me what the exact error is that is being fixed by this PR. Would you be able to describe the issue in more detail?
|
Hello, So, all I was trying to do was add a customField for discount amount on orderLine because the discount depends upon the exemptions file uploaded by the customer. Admin will later apply the discount and the order price will be recalculated once discoutn is applied. I was failing to trigger price recalculation and while looking into applyPriceAdjustments I had doubt that updated order lines are not saved correctly. All these despite OrderItemPriceCalculationStrategy getting triggered correctly. |
Hi, the scenario you describe sounds quite complex and I think I'd need to see an actual minimal reproduction in order to properly appreciate it. |
So in this loop vendure/packages/core/src/service/services/order.service.ts Lines 1687 to 1719 in 3dfb2d1
updatedOrderLines parameter object. This mutated updatedOrderLines object is never assigned to order.lines so when saving order.lines as in here
updatedOrderLines won't be saved to the db.
If you follow the call to vendure/packages/core/src/service/helpers/order-calculator/order-calculator.ts Lines 49 to 106 in 3dfb2d1
updatedOrderLines is never assigned to order.lines . Hence any changes made to orderLine is lost when you just save order.lines .
|
Thanks for the extra explanation.
Can you please show me the actual code implementation of this part - I don't fully understand what is going on here. |
https://github.com/BijanRegmi/vendure-price-issue Here's a minimal reproduction steps with a failing test case. |
Description
This patch fixes applyPriceAdjustment method for updated order lines.
Breaking changes
Does this PR include any breaking changes we should be aware of?
NO
Screenshots
You can add screenshots here if applicable.
Checklist
📌 Always:
👍 Most of the time: